//
//  NSString+Number.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/6/13.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "NSString+Number.h"

@implementation NSString (Number)

+ (NSString *)decimalwithFormat:(NSString *)format floatV:(float)floatV
{
    NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];

    [numberFormatter setPositiveFormat:format];

    return [numberFormatter stringFromNumber:[NSNumber numberWithFloat:floatV]];
}

- (NSString*)deleteFloatAllZero
{
    NSArray * arrStr=[self componentsSeparatedByString:@"."];
    NSString *str=arrStr.firstObject;
    NSString *str1=arrStr.lastObject;
    while ([str1 hasSuffix:@"0"]) {
        str1=[str1 substringToIndex:(str1.length-1)];
    }
    return (str1.length>0)?[NSString stringWithFormat:@"%@.%@",str,str1]:str;
}

@end
